package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.YmtAnliSettlementDetail;
import com.ymttest.utils.EnvSetup;

public class YmtAnliSettlementDetailWrapper {
	
	static SqlManager manage;

	public YmtAnliSettlementDetailWrapper() {
		if (manage == null || manage.getEnv() != "ymt" + EnvSetup.getEnv()
				|| manage.isClosed()) {
			manage = new SqlManager("ymt" + EnvSetup.getEnv());
		}
	}

	@SuppressWarnings("unchecked")
	public List<YmtAnliSettlementDetail> selectByOrderId(long orderId) {

		List<YmtAnliSettlementDetail> pia = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtAnliSettlementDetailMapper.selectByOrderId",
						orderId);
		return pia;
	}
	
	@SuppressWarnings("unchecked")
	public YmtAnliSettlementDetail selectByOrderIdAndCatalogId(long orderId, String catalogId) {

		HashMap<String, Object> map = new HashMap<>();
		
		map.put("orderId", orderId);
		map.put("catalogId", catalogId);
		
		List<YmtAnliSettlementDetail> pia = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtAnliSettlementDetailMapper.selectByOrderIdAndCatalogId",
						map);
		return pia.get(0);
	}
	
	public static void main(String[] args) {
		
		YmtAnliSettlementDetailWrapper wrapper = new YmtAnliSettlementDetailWrapper();
		
		System.out.println(wrapper.selectByOrderIdAndCatalogId(7421068699L, "c4309915").getProductId());
	}
}
